package com.xasqkj.seethedoctorwithphone.fragment;

import android.app.Activity;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.Context;
import android.util.Log;
import android.widget.TextView;

import com.xasqkj.seethedoctorwithphone.R;

/**
 * Created by YixuanNan on 16/4/7.
 */
public class FragmentPropertyManager {
    private volatile static Activity activity;
    private FragmentManager fragmentManager;

    private FragmentPropertyManager() {
    }

    public FragmentPropertyManager(Activity context) {
        this.activity = context;
        fragmentManager = context.getFragmentManager();


    }


    public void showFragment(FragmentProperty fragmentProperty) {
        FragmentTransaction transaction = fragmentManager.beginTransaction();
        if (fragmentManager.findFragmentByTag("" + fragmentProperty.getRid()) == null) {
            transaction.replace(R.id.fragment_content, MainFragment.newInstance(fragmentProperty.getRid()), "" + fragmentProperty.getRid());
            transaction.addToBackStack(null);
        } else {
            transaction.replace(R.id.fragment_content, fragmentManager.findFragmentByTag("" + fragmentProperty.getRid()));
        }
        transaction.commit();
    }
}

